package com.hsc.yalebao.face;

import android.content.res.AssetManager;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class FaceFragment extends Fragment
{
  private GridViewAdapter adapter;
  private List<FaceBean> faces = new ArrayList();
  private MyGridView gridview;
  private Handler handler;

  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    View localView = paramLayoutInflater.inflate(2130903127, null);
    this.gridview = ((MyGridView)localView.findViewById(2131099657));
    return localView;
  }

  public void onViewCreated(View paramView, Bundle paramBundle)
  {
    this.adapter = new GridViewAdapter(null);
    this.gridview.setAdapter(this.adapter);
    this.gridview.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
      public void onItemClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
      {
        try
        {
          Message localMessage = new Message();
          localMessage.obj = ((FaceBean)FaceFragment.this.faces.get(paramAnonymousInt)).getKey();
          FaceFragment.this.handler.sendMessage(localMessage);
          return;
        }
        catch (Exception localException)
        {
          localException.printStackTrace();
        }
      }
    });
    super.onViewCreated(paramView, paramBundle);
  }

  public void setFaces(List<FaceBean> paramList)
  {
    this.faces = paramList;
  }

  public void setHandler(Handler paramHandler)
  {
    this.handler = paramHandler;
  }

  private class GridViewAdapter extends BaseAdapter
  {
    private GridViewAdapter()
    {
    }

    public int getCount()
    {
      return FaceFragment.this.faces.size();
    }

    public Object getItem(int paramInt)
    {
      return FaceFragment.this.faces.get(paramInt);
    }

    public long getItemId(int paramInt)
    {
      return paramInt;
    }

    public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
    {
      if (paramView == null)
        paramView = LayoutInflater.from(FaceFragment.this.getActivity()).inflate(2130903131, null);
      ImageView localImageView = (ImageView)ViewHolder.get(paramView, 2131100131);
      try
      {
        InputStream localInputStream2 = FaceFragment.this.getActivity().getAssets().open("face" + File.separator + ((FaceBean)FaceFragment.this.faces.get(paramInt)).getImageName() + ".png");
        localInputStream1 = localInputStream2;
        if (localInputStream1 != null)
          localImageView.setImageBitmap(BitmapFactory.decodeStream(localInputStream1));
        return paramView;
      }
      catch (IOException localIOException)
      {
        while (true)
        {
          localIOException.printStackTrace();
          InputStream localInputStream1 = null;
        }
      }
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.face.FaceFragment
 * JD-Core Version:    0.6.2
 */